home *** CD-ROM | disk | FTP | other *** search
/ Apple Reference & Presen…tion Library 2 (Reseller) / Apple R&P Lib Reseller v2.0.iso / 4-Fonts & Software / Demo Software / AppMaker / Demo AppMaker™ / Demo AppMaker™.rsrc / TmpP_206_FilingMenu.txt < prev    next >
Text File  |  1989-04-09  |  6KB  |  2 lines

  1. # (decoded with TMPL 11972)
  2. { %filename% }{ Created %date% %time% by AppMaker }Unit %UnitName%;InterfaceUses%If MPW%    {$Load ToolBox.dump}        MemTypes,        QuickDraw,        OSIntf,        ToolIntf,        PackIntf,    {$Load}%end if%%If Think%{$ifc undefined Think_Pascal}    ListManager,{$endc}%end if%    %UsesDialogs%    Globals,    ResourceDefs,    Dispatcher,    Miscellany;{----------}Procedure Init%MenuName%;Function  OkToOpen (fType:    OSType): boolean;Procedure OpenFile (fileName:    Str255;                    vRefNum:    integer);Procedure Open0Files;Procedure DoClose;Procedure Do%MenuName% (itemNr:    integer);{----------}Implementation%If MPW%{$D+}{$R+}{$OV+}%end if%const    dialogTop        = 75;    dialogLeft        = 85;var    numOpenTypes:    integer;    openTypeList:    SFTypeList;%If MPW%{$S %unitname%}%end if%{----------}Procedure Init%MenuName%;Begin    numOpenTypes := 1;    openTypeList [0] := 'TEXT';End; {Init%MenuName%}{----------}Function OkToOpen {(fType:    OSType): boolean};var    i:                integer;    status:            (searching, found, notFound);Begin    i := 0;    status := searching;    while status = searching do begin        if i >= numOpenTypes then begin            status := notFound;        end else begin            if fType = openTypeList [i] then begin                status := found;            end else begin                i := i + 1;            end;        end;    end; {while}    OkToOpen := (status = found);End; {OkToOpen}{----------}Function OpenApplFile (vRefNum:        integer;                       fName:        Str255;                   var fRefNum:        integer): boolean;var    ok:                boolean;Begin  { application-specific Open file }    ok := CheckOS (FSOpen (fName, vRefNum, fRefNum));    OpenApplFile := ok;End; {OpenApplFile}{----------}Procedure CloseApplFile (fRefNum:    integer);var    ok:                boolean;Begin  { application-specific Close file }      if ord (cur^.windowKind) = 1 then begin {1st or only window in set}        ok := CheckOS (FSClose (fRefNum));    end;End; {CloseApplFile}{----------}Procedure SaveApplFile (fRefNum:    integer);Begin  { application-specific Save file }    cur^.dirty := false;End; {SaveApplFile}{----------}Function ReadApplFile (fRefNum:        integer): boolean;Begin  { application-specific Read file }      ReadApplFile := false;End; {ReadApplFile}{----------}Procedure DoNew;var    nameHandle:        StringHandle;    name:            Str255;Begin    nameHandle := GetString (UntitledID);    name := nameHandle^^;    OpenWindows (name, 0, 0);End; {DoNew} {----------}Procedure OpenFile {(fileName:    Str255;                     vRefNum:    integer)};var    fRefNum:        integer;Begin    if OpenApplFile (vRefNum, fileName, fRefNum) then begin        OpenWindows (fileName, vRefNum, fRefNum);    end; {if}    End; {OpenFile} {----------}Procedure DoOpen;var    dialogOrigin:    Point;    sfInfo:            SFReply;Begin    SetPt (dialogOrigin, dialogLeft, dialogTop);    SFGetFile (dialogOrigin, '', nil, numOpenTypes, openTypeList, nil, sfInfo);    with sfInfo do begin        if good then begin            openFile (fName, vRefNum);        end;    end;End; {DoOpen} {----------}Procedure Open0Files;Begin    DoNew;End; {Open0Files} {----------}Procedure DoSaveAs;var    sfInfo:            SFReply;    fRefNum:        integer;    ok:                boolean;    prompt:            StringHandle;    suggestion:        Str255;    untitled:        StringHandle;Begin    prompt := GetString (SaveAsPromptID);    suggestion := '';    with sfInfo do begin        if CreateFile (sfInfo, prompt^^, suggestion, 'XXXX', 'TEXT')        then begin            if cur^.fileNum <> 0 then begin                CloseApplFile (cur^.fileNum);            end;            if OpenApplFile (vRefNum, fName, fRefNum) then begin                SetWTitle (curWindow, fName);                cur^.fileNum := fRefNum;                cur^.volNum := vRefNum;                SaveApplFile (cur^.fileNum);            end else begin {should never happen}                untitled := GetString (UntitledID);                SetWTitle (curWindow, untitled^^);                cur^.fileNum := 0;                cur^.volNum := 0;            end; {if}        end; {if}    end; {with}End; {DoSaveAs} {----------}Procedure DoSave;Begin    if cur^.fileNum = 0 then begin        DoSaveAs;    end else begin        SaveApplFile (cur^.fileNum);    end;End; {DoSave} {----------}Procedure CloseApplWindow;const    saveItem        = 1;    cancelItem      = 2;    discardItem     = 3;    var    curTitle:        Str255;    itemNum:        integer;    ok:                boolean;Begin    ok := true;    SetInfo (FrontWindow);    if cur^.dirty then begin        GetWTitle (curWindow, curTitle);        ParamText (curTitle, '', '', '');        InitCursor;        itemNum := Alert (SaveID, nil);        Case itemNum of            saveItem: begin                    DoSave;                    ok := not errorFlag;                end;            discardItem:                   {Do nothing};            cancelItem: begin                    errorFlag := true;                    ok := false;                end;        end; {case}    end;    if ok then begin        if cur^.fileNum <> 0 then begin            CloseApplFile (cur^.fileNum);        end;        CloseCurWindow;    end;End; {CloseApplWindow} {----------}Procedure DoClose;var    frontPeek:        WindowPeek;Begin    frontPeek := WindowPeek (FrontWindow);    if frontPeek^.windowKind < 0 then begin        CloseDeskAcc (frontPeek^.windowKind);    end else if frontPeek^.windowKind = dialogKind then begin        CloseModelessDialog (FrontWindow);    end else begin        CloseApplWindow;    end;End; {DoClose}{----------}Procedure DoQuit;var    quitting:        boolean;                             Begin    quitting := true;    while quitting and (FrontWindow <> nil) do begin        SystemTask;        DoClose;        if errorFlag then begin            quitting := false;        end;    end; {while}        if quitting then begin        quittingTime := true;    end;End; {DoQuit} %DoMenuItems%{----------}Procedure Do%MenuName% {(itemNr:    integer)};Begin    errorFlag := false;    case itemNr of        %HandleMenuItems%    end; {case}End; {Do%MenuName%}End. {%UnitName%}